/*
 * @Author: 元辰
 * @Date: 2023-06-28 14:13:48
 * @LastEditTime: 2023-06-28 18:16:34
 * @LastEditors: 元辰
 */

const Koa = require('koa');
const bodyParser = require('koa-bodyparser')();
const router = require('./utils/router')();
const cors = require('./utils/cors')();

const app = new Koa();

const port = 5200;

app.use(bodyParser);
app.use(router);
app.use(cors);

app.use(async (ctx, next) => {
  console.log(`调用, 方式：${ctx.request.method}, 路由：${ctx.request.url}`);
  await next();
});

console.log(`项目启动于：localhost:${port}`);
app.listen(port);